/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainWindow.java
 *
 * Created on Mar 29, 2011, 9:27:25 PM
 */

package view;


import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author borysfan
 */
public class MainWindow extends JFrame {

    public MainWindow() {
        initComponents();
        initWindow();
       
    }

    private void initWindow(){
        addPropertiesPanel();

        //Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
       // int width = getWidth();
       // int height = getHeight();
        //this.setBounds((screen.width-width)/2, (screen.height-height)/2, width, height);
        
        

    }

   
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        toolbarPanel = new javax.swing.JPanel();
        propertiesPanel = new javax.swing.JPanel();
        simulationBtn = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        openItem = new javax.swing.JMenuItem();
        saveItem = new javax.swing.JMenuItem();
        saveAsItem = new javax.swing.JMenuItem();
        printToFileBtn = new javax.swing.JMenuItem();
        closeMenuItem = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        label = new javax.swing.JCheckBoxMenuItem();
        icon = new javax.swing.JCheckBoxMenuItem();
        jMenu2 = new javax.swing.JMenu();
        helpMenuItem = new javax.swing.JMenuItem();
        aboutBtn = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Węzeł komunikacyjny");
        setMinimumSize(new java.awt.Dimension(954, 652));
        setResizable(false);
        getContentPane().setLayout(null);

        mainPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        mainPanel.setLayout(null);
        getContentPane().add(mainPanel);
        mainPanel.setBounds(10, 11, 0, 0);

        toolbarPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        toolbarPanel.setLayout(null);
        getContentPane().add(toolbarPanel);
        toolbarPanel.setBounds(586, 11, 0, 0);

        propertiesPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        propertiesPanel.setLayout(null);
        getContentPane().add(propertiesPanel);
        propertiesPanel.setBounds(586, 134, 0, 0);

        simulationBtn.setText("Symulacja");
        getContentPane().add(simulationBtn);
        simulationBtn.setBounds(586, 526, 358, 64);

        jMenu1.setText("Plik");

        newMenuItem.setText("Nowy...");
        jMenu1.add(newMenuItem);

        openItem.setText("Otwórz...");
        jMenu1.add(openItem);

        saveItem.setText("Zapisz");
        jMenu1.add(saveItem);

        saveAsItem.setText("Zapisz jako ...");
        jMenu1.add(saveAsItem);

        printToFileBtn.setText("Drukuj do pliku");
        jMenu1.add(printToFileBtn);

        closeMenuItem.setText("Zamknij");
        jMenu1.add(closeMenuItem);

        jMenuBar1.add(jMenu1);

        jMenu3.setText("Ustawienia");

        label.setSelected(true);
        label.setText("Pokazuj etykiety");
        jMenu3.add(label);

        icon.setSelected(true);
        icon.setText("Pokazuj ikony");
        jMenu3.add(icon);

        jMenuBar1.add(jMenu3);

        jMenu2.setText("Pomoc");

        helpMenuItem.setText("Pomoc");
        jMenu2.add(helpMenuItem);

        aboutBtn.setText("O Programie");
        jMenu2.add(aboutBtn);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    
    // NIE KRZYCZ TO TESTOWE PRZYCISKI
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem aboutBtn;
    private javax.swing.JMenuItem closeMenuItem;
    private javax.swing.JMenuItem helpMenuItem;
    private javax.swing.JCheckBoxMenuItem icon;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JCheckBoxMenuItem label;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuItem newMenuItem;
    private javax.swing.JMenuItem openItem;
    private javax.swing.JMenuItem printToFileBtn;
    private javax.swing.JPanel propertiesPanel;
    private javax.swing.JMenuItem saveAsItem;
    private javax.swing.JMenuItem saveItem;
    private javax.swing.JButton simulationBtn;
    private javax.swing.JPanel toolbarPanel;
    // End of variables declaration//GEN-END:variables
    private javax.swing.JPanel edgePanel;
    private javax.swing.JPanel nodePanel;
    private MainPanel targetPanel;

    

     public void addSimulationAction(ActionListener listener){
        simulationBtn.addActionListener(listener);
    }

   
    public void addCloseAction(ActionListener listener) {
        closeMenuItem.addActionListener(listener);
    }

    public void addNewAction(ActionListener listener) {
        newMenuItem.addActionListener(listener);
    }


  public void addToolboxPanel(ToolboxPanel panel){
       getContentPane().remove(toolbarPanel);
       toolbarPanel = panel;
       toolbarPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
       toolbarPanel.setBounds(586, 11, 358, 112);
       getContentPane().add(toolbarPanel);
       pack();
   }

   public void addPropertiesPanel(){
       propertiesPanel = new javax.swing.JPanel();
       propertiesPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
       propertiesPanel.setBounds(586, 123, 358, 400);
       getContentPane().add(propertiesPanel);
       propertiesPanel.setVisible(false);
       pack();
   }


    public void addMainPanel(MainPanel view) {
       targetPanel = view;
       targetPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
       targetPanel.setBounds(10, 11, 570, 579);
       getContentPane().add(targetPanel);
       pack();
    }

    public void addNodePanel(NodePanel view) {
       nodePanel = view;
       nodePanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
       nodePanel.setBounds(586, 123, 358, 400);
       getContentPane().add(nodePanel);
       nodePanel.setVisible(false);
       pack();
    }

    public void addEdgePanel(EdgePanel view){
       edgePanel = view;
       edgePanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
       edgePanel.setBounds(586, 123, 358, 400);
       getContentPane().add(edgePanel);
       edgePanel.setVisible(false);
       pack();
    }

    public void showNodePanel() {
       
        nodePanel.show();
        edgePanel.hide();
        propertiesPanel.hide();
        nodePanel.repaint();
    }

    public void showEdgePanel() {
        nodePanel.hide();
        edgePanel.show();
        propertiesPanel.hide();
        edgePanel.repaint();
    }


    public void showPropertiesPanel(){
        nodePanel.hide();
        edgePanel.hide();
        propertiesPanel.show();
        propertiesPanel.repaint();
    }
public boolean getShowIcons(){
        return icon.isSelected();
    }
    
    public void setShowIcons(boolean icons){
        icon.setSelected(icons);
    }
    
    public boolean getShowLabel(){
        return label.isSelected();
    }
    
    public void setShowLabels(boolean labels){
        label.setSelected(labels);
    }

    public void setHelpButton(ActionListener listener){
        helpMenuItem.addActionListener(listener);
    }

    public void setIconsButton(ActionListener listener){
        icon.addActionListener(listener);
    }

    public void setLabelButton(ActionListener listener){
        label.addActionListener(listener);
    }

    public void setOpenAction(ActionListener listener) {
        openItem.addActionListener(listener);
    }

    public void setSaveAction(ActionListener listener) {
       saveItem.addActionListener(listener);
    }

    public void setSaveAsAction(ActionListener listener) {
        saveAsItem.addActionListener(listener);
    }

    public void setAboutProgramAction(ActionListener listener){
        aboutBtn.addActionListener(listener);
    }

    public void setPrintToFileBtn(ActionListener listener){
        printToFileBtn.addActionListener(listener);
    }
    
  }
